package test;

//import bilder;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class ImageIconExample extends JFrame{
	private ImageIcon img;
	private ImageIcon img2;
	private JLabel label;
	private JLabel label2;
	
	public ImageIconExample(){
		this.setPreferredSize(new Dimension(400,500));
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		// Main Panel
		JPanel plMain = new JPanel();
		plMain.setLayout(new BorderLayout());
		this.getContentPane().add(plMain, BorderLayout.CENTER);
	
		//Bild label hinzufuegen
		//getResource is -as mattb says- for loading resources from the classpath (from your .jar or classpath directory).
		img = new ImageIcon(getClass().getResource("/test/bilder/achtung.jpg"));
		label = new JLabel(img);
		//Alternative: label.setIcon(img);
		
		//Variante ohne zusaetzliches package
		img2 = new ImageIcon(getClass().getResource("boulanger.gif"));
		label2 = new JLabel(img2);
		
		plMain.add(label, BorderLayout.NORTH);
		plMain.add(label2,BorderLayout.SOUTH);
		
		this.pack();
	}
	
	public static void main( String[] args ){
		new ImageIconExample().setVisible( true );
	}
}